<!DOCTYPE html>
<!-- saved from url=(0040)https://www.runoob.com/js/js-regexp.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
  <meta property="qc:admins" content="465267610762567726375">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>JavaScript 正则表达式 | 菜鸟教程</title>

  <link rel="dns-prefetch" href="https://s.w.org/">
<link rel="canonical" href="http://www.runoob.com/js/js-regexp.html">
<meta name="keywords" content="JavaScript 正则表达式">
<meta name="description" content="JavaScript 正则表达式   正则表达式（英语：Regular Expression，在代码中常简写为regex、regexp或RE）使用单个字符串来描述、匹配一系列符合某个句法规则的字符串搜索模式。 搜索模式可用于文本搜索和文本替换。   什么是正则表达式？ 正则表达式是由一个字符序列形成的搜索模式。 当你在文本中搜索数据时，你可以用搜索模式来描述你要查询的内容。 正则表达式可以是一个简单的字符，或一个更复杂的模式。 正则表达..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico" mce_href="//static.runoob.com/images/favicon.ico" type="image/x-icon">
	<link rel="stylesheet" href="./JavaScript 正则表达式 _ 菜鸟教程_files/style.css" type="text/css" media="all">	
	<link rel="stylesheet" href="./JavaScript 正则表达式 _ 菜鸟教程_files/font-awesome.min.css" media="all">	
  <!--[if gte IE 9]><!-->
  <script type="text/javascript" async="" src="./JavaScript 正则表达式 _ 菜鸟教程_files/analytics.js.下载"></script><script src="./JavaScript 正则表达式 _ 菜鸟教程_files/osd.js.下载"></script><script src="./JavaScript 正则表达式 _ 菜鸟教程_files/hm.js.下载"></script><script src="./JavaScript 正则表达式 _ 菜鸟教程_files/ca-pub-5751451760833794.js.下载"></script><script src="./JavaScript 正则表达式 _ 菜鸟教程_files/jquery.min.js.下载"></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src="//cdn.staticfile.org/jquery/1.9.1/jquery.min.js"></script>
     <script src="//cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png">
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
<link rel="preload" href="./JavaScript 正则表达式 _ 菜鸟教程_files/f(4).txt" as="script"><script type="text/javascript" src="./JavaScript 正则表达式 _ 菜鸟教程_files/f(4).txt"></script><link rel="preload" href="https://pagead2.googlesyndication.com/pagead/js/r20190617/r20190131/show_ads_impl.js" as="script"><link rel="stylesheet" type="text/css" href="./JavaScript 正则表达式 _ 菜鸟教程_files/prettify.css"></head>
<body style="">

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="https://www.runoob.com/js/index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="https://www.runoob.com/">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        <div class="col search search-desktop last">
      <form action="https://www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……" autocomplete="off">
      </form>
    </div>
  </div>
</div>


<!-- 导航栏 -->
<!-- 导航栏 -->
<div class="container navigation">
	<div class="row">
		<div class="col nav">
			<ul class="pc-nav">
				<li><a href="https://www.runoob.com/">首页</a></li>
				<li><a href="https://www.runoob.com/html/html-tutorial.html">HTML</a></li>
				<li><a href="https://www.runoob.com/css/css-tutorial.html">CSS</a></li>
				<li><a href="https://www.runoob.com/js/js-tutorial.html">JavaScript</a></li>
				<li><a href="https://www.runoob.com/jquery/jquery-tutorial.html">jQuery</a></li>
				<li><a href="https://www.runoob.com/bootstrap/bootstrap-tutorial.html">Bootstrap</a></li>
				<li><a href="https://www.runoob.com/sql/sql-tutorial.html">SQL</a></li>
				<li><a href="https://www.runoob.com/mysql/mysql-tutorial.html">MySQL</a></li>
				<li><a href="https://www.runoob.com/php/php-tutorial.html">PHP</a></li>
				<li><a href="https://www.runoob.com/python/python-tutorial.html">Python2</a></li>
				<li><a href="https://www.runoob.com/python3/python3-tutorial.html">Python3</a></li>
				<li><a href="https://www.runoob.com/cprogramming/c-tutorial.html">C</a></li>
				<li><a href="https://www.runoob.com/cplusplus/cpp-tutorial.html">C++</a></li>
				<li><a href="https://www.runoob.com/csharp/csharp-tutorial.html">C#</a></li>
				<li><a href="https://www.runoob.com/java/java-tutorial.html">Java</a></li>
				<li><a href="https://www.runoob.com/browser-history">本地书签</a></li>
				<!--
				<li><a href="/w3cnote/knowledge-start.html" style="font-weight: bold;" onclick="_hmt.push(['_trackEvent', '星球', 'click', 'start'])" title="我的圈子">我的圈子</a></li>				
				<li><a href="javascript:;" class="runoob-pop">登录</a></li>
				-->
      		</ul>
			<ul class="mobile-nav">
				<li><a href="https://www.runoob.com/">首页</a></li>
				<li><a href="https://www.runoob.com/html/html-tutorial.html">HTML</a></li>
				<li><a href="https://www.runoob.com/css/css-tutorial.html">CSS</a></li>
				<li><a href="https://www.runoob.com/js/js-tutorial.html">JS</a></li>
				<li><a href="https://www.runoob.com/browser-history">本地书签</a></li>
				<a href="javascript:void(0)" class="search-reveal">Search</a> 
			</ul>
			
		</div>
	</div>
</div><!--  内容  -->
<div class="container main">
	<!-- 中间 -->
	<div class="row">
	
<div class="col left-column">
	<div class="tab">Javascript 教程	<a data-cate="7" href="javascript:void(0);" title="夜间模式" id="moon"><i class="fa fa-moon-o" aria-hidden="true" style="font-size: 1.4em;float: right;margin: 4px 6px 0;"></i></a>
	<a data-cate="7" style="display:none;" href="javascript:void(0);" title="日间模式" id="sun"><i class="fa fa-sun-o" aria-hidden="true" style="font-size: 1.4em;float: right;margin: 4px 6px 0;"></i></a>
	</div>
	<div class="sidebar-box gallery-list">
		<div class="design" id="leftcolumn">
						<a target="_top" title="JavaScript 教程" href="https://www.runoob.com/js/js-tutorial.html">
			JavaScript 教程			</a>
						<a target="_top" title="JavaScript 简介" href="https://www.runoob.com/js/js-intro.html">
			JavaScript 简介			</a>
						<a target="_top" title="JavaScript 用法" href="https://www.runoob.com/js/js-howto.html">
			JavaScript 用法			</a>
						<a target="_top" title="JavaScript 输出" href="https://www.runoob.com/js/js-output.html">
			JavaScript 输出			</a>
			<a target="_top" title="JavaScript 语法 " href="https://www.runoob.com/js/js-syntax.html"> JavaScript 语法 </a>			<a target="_top" title="JavaScript 语句" href="https://www.runoob.com/js/js-statements.html">
			JavaScript 语句			</a>
						<a target="_top" title="JavaScript 注释" href="https://www.runoob.com/js/js-comments.html">
			JavaScript 注释			</a>
						<a target="_top" title="JavaScript  变量" href="https://www.runoob.com/js/js-variables.html">
			JavaScript  变量			</a>
						<a target="_top" title="JavaScript 数据类型" href="https://www.runoob.com/js/js-datatypes.html">
			JavaScript 数据类型			</a>
						<a target="_top" title="JavaScript 对象" href="https://www.runoob.com/js/js-obj-intro.html">
			JavaScript 对象			</a>
						<a target="_top" title="JavaScript 函数" href="https://www.runoob.com/js/js-functions.html">
			JavaScript 函数			</a>
			<a target="_top" title="JavaScript 作用域" href="https://www.runoob.com/js/js-scope.html"> JavaScript 作用域 </a>
<a target="_top" title="JavaScript 事件" href="https://www.runoob.com/js/js-events.html"> JavaScript 事件 </a>
<a target="_top" title="JavaScript 字符串" href="https://www.runoob.com/js/js-strings.html"> JavaScript 字符串</a>			<a target="_top" title="JavaScript 运算符" href="https://www.runoob.com/js/js-operators.html">
			JavaScript 运算符			</a>
						<a target="_top" title="JavaScript 比较和逻辑运算符" href="https://www.runoob.com/js/js-comparisons.html">
			JavaScript 比较			</a>
						<a target="_top" title="JavaScript If…Else 语句" href="https://www.runoob.com/js/js-if-else.html">
			JavaScript 条件语句			</a>
						<a target="_top" title="JavaScript switch 语句" href="https://www.runoob.com/js/js-switch.html">
			JavaScript switch 语句			</a>
						<a target="_top" title="JavaScript for 循环" href="https://www.runoob.com/js/js-loop-for.html">
			JavaScript for 循环			</a>
						<a target="_top" title="JavaScript while 循环" href="https://www.runoob.com/js/js-loop-while.html">
			JavaScript while 循环			</a>
						<a target="_top" title="JavaScript Break 和 Continue 语句" href="https://www.runoob.com/js/js-break.html">
			JavaScript Break 和 Continue 语句			</a>
			<a target="_top" title="JavaScript typeof" href="https://www.runoob.com/js/js-typeof.html"> JavaScript typeof </a>
<a target="_top" title="JavaScript 类型转换" href="https://www.runoob.com/js/js-type-conversion.html"> JavaScript 类型转换 </a>
<a target="_top" title="JavaScript 正则表达式" href="https://www.runoob.com/js/js-regexp.html" style="background-color: rgb(150, 185, 125); font-weight: bold; color: rgb(255, 255, 255);"> JavaScript 正则表达式 </a>			<a target="_top" title="JavaScript 错误 – Throw、Try 和 Catch" href="https://www.runoob.com/js/js-errors.html">
			JavaScript  错误			</a>
			<a target="_top" title="JavaScript 调试" href="https://www.runoob.com/js/js-debugging.html"> JavaScript 调试</a>
<a target="_top" title="JavaScript 变量提升" href="https://www.runoob.com/js/js-hoisting.html"> JavaScript 变量提升</a>
<a target="_top" title="JavaScript 严格模式" href="https://www.runoob.com/js/js-strict.html"> JavaScript 严格模式</a>
<a target="_top" title="JavaScript 使用误区" href="https://www.runoob.com/js/js-mistakes.html"> JavaScript 使用误区</a>
<a target="_top" title="JavaScript 表单" href="https://www.runoob.com/js/js-validation.html"> JavaScript 表单
</a>			<a target="_top" title="JavaScript 表单验证" href="https://www.runoob.com/js/js-form-validation.html">
			JavaScript 表单验证			</a>
			<a target="_top" href="https://www.runoob.com/js/js-validation-api.html">
JavaScript 验证 API</a>
<a target="_top" href="https://www.runoob.com/js/js-reserved.html">	JavaScript 保留关键字	</a>
<a target="_top" href="https://www.runoob.com/js/js-this.html">	JavaScript this	</a>
<a target="_top" href="https://www.runoob.com/js/js-let-const.html">	JavaScript let 和 const	</a>

<a target="_top" href="https://www.runoob.com/js/js-json.html"> JavaScript JSON	</a>
<a target="_top" href="https://www.runoob.com/js/js-void.html"> JavaScript void </a>

<a target="_top" href="https://www.runoob.com/js/js-conventions.html"> JavaScript 代码规范 </a>
<br>
<h2 class="left"><span class="left_h2">JS</span> 函数</h2>
<a target="_top" title="JavaScript 函数定义" href="https://www.runoob.com/js/js-function-definition.html"> JavaScript 函数定义 </a>
<a target="_top" title="JavaScript 函数参数" href="https://www.runoob.com/js/js-function-parameters.html"> JavaScript 函数参数 </a>
<a target="_top" title="JavaScript 函数调用" href="https://www.runoob.com/js/js-function-invocation.html"> JavaScript 函数调用 </a>
<a target="_top" title="JavaScript 闭包" href="https://www.runoob.com/js/js-function-closures.html"> JavaScript 闭包 </a>
<br>
<h2 class="left"><span class="left_h2">JS</span> HTML DOM</h2>			<a target="_top" title="JavaScript HTML DOM" href="https://www.runoob.com/js/js-htmldom.html">
			DOM 简介			</a>
						<a target="_top" title="JavaScript HTML DOM 改变 HTML 内容" href="https://www.runoob.com/js/js-htmldom-html.html">
			DOM HTML			</a>
						<a target="_top" title="JavaScript HTML DOM 改变 CSS" href="https://www.runoob.com/js/js-htmldom-css.html">
			DOM CSS			</a>
						<a target="_top" title="JavaScript HTML DOM 事件" href="https://www.runoob.com/js/js-htmldom-events.html">
			DOM 事件			</a>
			<a target="_top" href="https://www.runoob.com/js/js-htmldom-eventlistener.html">DOM EventListener</a>			<a target="_top" title="JavaScript HTML DOM 元素 (节点)" href="https://www.runoob.com/js/js-htmldom-elements.html">
			DOM 元素			</a>
			<a target="_top" title="JavaScript HTML DOM 集合(Collection)" href="https://www.runoob.com/js/js-htmldom-collections.html"> HTMLCollection 对象 </a>

<a target="_top" title="JavaScript HTML DOM 节点列表" href="https://www.runoob.com/js/js-htmldom-nodelist.html"> NodeList 对象 </a>
<br><h2 class="left"><span class="left_h2">JS</span> 高级教程</h2>			<a target="_top" title="JavaScript 对象" href="https://www.runoob.com/js/js-objects.html">
			JavaScript 对象			</a>
			<a target="_top" title="JavaScript prototype" href="https://www.runoob.com/js/js-object-prototype.html"> JavaScript prototype
</a>			<a target="_top" title="JavaScript Number 对象" href="https://www.runoob.com/js/js-obj-number.html">
			JavaScript Number 对象			</a>
						<a target="_top" title="JavaScript 字符串（String）对象" href="https://www.runoob.com/js/js-obj-string.html">
			JavaScript String			</a>
						<a target="_top" title="JavaScript Date（日期）对象" href="https://www.runoob.com/js/js-obj-date.html">
			JavaScript Date（日期）			</a>
						<a target="_top" title="JavaScript  Array（数组）对象" href="https://www.runoob.com/js/js-obj-array.html">
			JavaScript  Array（数组）			</a>
						<a target="_top" title="JavaScript Boolean（布尔）对象" href="https://www.runoob.com/js/js-obj-boolean.html">
			JavaScript Boolean（布尔）			</a>
						<a target="_top" title="JavaScript Math（算数）对象" href="https://www.runoob.com/js/js-obj-math.html">
			JavaScript Math（算数）			</a>
						<a target="_top" title="JavaScript RegExp 对象" href="https://www.runoob.com/js/js-obj-regexp.html">
			JavaScript RegExp 对象			</a>
			<br><h2 class="left"><span class="left_h2">JS</span> 浏览器BOM</h2>			<a target="_top" title="JavaScript Window" href="https://www.runoob.com/js/js-window.html">
			JavaScript Window			</a>
						<a target="_top" title="JavaScript Window Screen" href="https://www.runoob.com/js/js-window-screen.html">
			JavaScript Window Screen			</a>
						<a target="_top" title="JavaScript Window Location" href="https://www.runoob.com/js/js-window-location.html">
			JavaScript Window Location			</a>
						<a target="_top" title="JavaScript Window History" href="https://www.runoob.com/js/js-window-history.html">
			JavaScript Window History			</a>
						<a target="_top" title="JavaScript Window Navigator" href="https://www.runoob.com/js/js-window-navigator.html">
			JavaScript Navigator			</a>
						<a target="_top" title="JavaScript 弹窗" href="https://www.runoob.com/js/js-popup.html">
			JavaScript 弹窗			</a>
						<a target="_top" title="JavaScript 计时事件" href="https://www.runoob.com/js/js-timing.html">
			JavaScript 计时事件			</a>
						<a target="_top" title="JavaScript Cookie" href="https://www.runoob.com/js/js-cookies.html">
			JavaScript Cookie			</a>
			<br><h2 class="left"><span class="left_h2">JS</span> 库</h2>			<a target="_top" title="JavaScript 库" href="https://www.runoob.com/js/js-libraries.html">
			JavaScript 库			</a>
						<a target="_top" title="JavaScript 测试 jQuery" href="https://www.runoob.com/js/js-lib-jquery.html">
			JavaScript 测试 jQuery			</a>
						<a target="_top" title="JavaScript 测试 Prototype" href="https://www.runoob.com/js/js-lib-prototype.html">
			JavaScript 测试 Prototype			</a>
			<br><h2 class="left"><span class="left_h2">JS</span> 实例</h2>			<a target="_top" title="JavaScript 实例" href="https://www.runoob.com/js/js-examples.html">
			JavaScript 实例			</a>
						<a target="_top" title="JavaScript 对象实例" href="https://www.runoob.com/js/js-ex-objects.html">
			JavaScript 对象实例			</a>
						<a target="_top" title="JavaScript 浏览器对象实例" href="https://www.runoob.com/js/js-ex-browser.html">
			JavaScript 浏览器对象实例			</a>
						<a target="_top" title="JavaScript HTML DOM 实例" href="https://www.runoob.com/js/js-ex-dom.html">
			JavaScript HTML DOM 实例			</a>
						<a target="_top" title="JavaScript 总结" href="https://www.runoob.com/js/js-summary.html">
			JavaScript 总结			</a>
			<br><h2 class="left"><span class="left_h2">JS</span> 参考手册</h2>
<a target="_top" href="https://www.runoob.com/jsref/jsref-tutorial.html">JavaScript 对象</a>
<a target="_top" href="https://www.runoob.com/jsref/dom-obj-document.html">HTML DOM 对象</a>	
		</div>
	</div>	
</div>	<div class="col middle-column">
		
	
	<div class="article">
			<div class="article-heading-ad" style="display: none;">
		
		</div>
		<div class="previous-next-links">
			<div class="previous-design-link"><a href="https://www.runoob.com/js/js-type-conversion.html"><i style="font-size:16px;" class="fa fa-arrow-left" aria-hidden="true"></i></a> <a href="https://www.runoob.com/js/js-type-conversion.html" rel="prev" title="JavaScript 类型转换">JavaScript 类型转换</a> </div>
			<div class="next-design-link"><a href="https://www.runoob.com/js/js-errors.html" rel="next" title="JavaScript 错误 – Throw、Try 和 Catch">JavaScript 错误 – Throw、Try 和 Catch</a> <a href="https://www.runoob.com/js/js-errors.html"><i style="font-size:16px;" class="fa fa-arrow-right" aria-hidden="true"></i></a></div>
		</div>
		<div class="article-body">
		
			<div class="article-intro" id="content">
			
			<h1>JavaScript <span class="color_h1">正则表达式</span></h1>

<hr>
<p class="intro">正则表达式（英语：Regular Expression，在代码中常简写为regex、regexp或RE）使用单个字符串来描述、匹配一系列符合某个句法规则的字符串搜索模式。</p>
<p class="intro">搜索模式可用于文本搜索和文本替换。</p>
<hr>

<h2>什么是正则表达式？</h2>
<p>正则表达式是由一个字符序列形成的搜索模式。</p>
<p>当你在文本中搜索数据时，你可以用搜索模式来描述你要查询的内容。</p>
<p>正则表达式可以是一个简单的字符，或一个更复杂的模式。</p>
<p>正则表达式可用于所有文本搜索和文本替换的操作。</p>

<h2>语法</h2>
<pre class="prettyprint prettyprinted" style=""><span class="str">/正则表达式主体/</span><span class="pun">修饰符(可选)</span></pre>
<p>其中修饰符是可选的。</p>
<br>

<div class="example">
<h2 class="example">实例：</h2>
<div class="example_code">
	var patt = /runoob/i</div>
</div>
<p>实例解析：</p>
<p><strong>/runoob/i</strong>&nbsp; 是一个正则表达式。</p>
<p><strong>runoob</strong>&nbsp; 是一个<strong>正则表达式主体</strong> (用于检索)。</p>
<p><strong>i</strong>&nbsp; 是一个<strong>修饰符</strong> (搜索不区分大小写)。</p>
<hr>

<h2>使用字符串方法</h2>
<p>在 JavaScript 中，正则表达式通常用于两个字符串方法 : search() 和 replace()。</p>
<p><strong>search() 方法</strong> 用于检索字符串中指定的子字符串，或检索与正则表达式相匹配的子字符串，并返回子串的起始位置。</p>
<p><strong>replace() 方法</strong> 用于在字符串中用一些字符替换另一些字符，或替换一个与正则表达式匹配的子串。</p>
<hr>

<h2> search() 方法使用正则表达式</h2>

<div class="example">
<h2 class="example">实例</h2>
<p>使用正则表达式搜索 "Runoob" 字符串，且不区分大小写：</p>
<div class="example_code">
<div class="hl-main"><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">str</span><span class="hl-code"> = </span><span class="hl-quotes">"</span><span class="hl-string">Visit Runoob!</span><span class="hl-quotes">"</span><span class="hl-code">; 
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">n</span><span class="hl-code"> = </span><span class="hl-identifier">str</span><span class="hl-code">.</span><span class="hl-identifier">search</span><span class="hl-brackets">(</span><span class="hl-code">/</span><span class="hl-identifier">Runoob</span><span class="hl-code">/</span><span class="hl-identifier">i</span><span class="hl-brackets">)</span><span class="hl-code">;</span></div>
</div>
<p>输出结果为：</p>
<div class="example_code">
6
</div>
<br>
<a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_string_search_regexp" target="_blank">尝试一下 »</a></div>
<br>
<hr>

<h2>search() 方法使用字符串</h2>
<p>search 方法可使用字符串作为参数。字符串参数会转换为正则表达式： </p>

<div class="example">
<h2 class="example">实例</h2>
<p>检索字符串中 "Runoob" 的子串：</p>
<div class="example_code">
<div class="hl-main"><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">str</span><span class="hl-code"> = </span><span class="hl-quotes">"</span><span class="hl-string">Visit Runoob!</span><span class="hl-quotes">"</span><span class="hl-code">; 
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">n</span><span class="hl-code"> = </span><span class="hl-identifier">str</span><span class="hl-code">.</span><span class="hl-identifier">search</span><span class="hl-brackets">(</span><span class="hl-quotes">"</span><span class="hl-string">Runoob</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">;</span></div>
</div>
<br>
<a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_string_search" target="_blank">尝试一下 »</a>
</div>
<br>
<hr>

<h2>replace() 方法使用正则表达式</h2>

<div class="example">
<h2 class="example">实例</h2>
<p>使用正则表达式且不区分大小写将字符串中的 Microsoft 替换为 Runoob :</p>
<div class="example_code">
<div class="hl-main"><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">str</span><span class="hl-code"> = </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementById</span><span class="hl-brackets">(</span><span class="hl-quotes">"</span><span class="hl-string">demo</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">.</span><span class="hl-identifier">innerHTML</span><span class="hl-code">; 
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">txt</span><span class="hl-code"> = </span><span class="hl-identifier">str</span><span class="hl-code">.</span><span class="hl-identifier">replace</span><span class="hl-brackets">(</span><span class="hl-code">/</span><span class="hl-identifier">microsoft</span><span class="hl-code">/</span><span class="hl-identifier">i</span><span class="hl-code">,</span><span class="hl-quotes">"</span><span class="hl-string">Runoob</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">;</span></div>
</div>
<p>结果输出为:</p>
<div class="example_code">
Visit Runoob!</div>
<br>
<a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_string_replace_regexp" target="_blank">尝试一下 »</a>
</div>
<br>
<h2>replace() 方法使用字符串</h2>
<p>replace() 方法将接收字符串作为参数：</p>

<div class="example">
<div class="example_code">
<div class="hl-main"><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">str</span><span class="hl-code"> = </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementById</span><span class="hl-brackets">(</span><span class="hl-quotes">"</span><span class="hl-string">demo</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">.</span><span class="hl-identifier">innerHTML</span><span class="hl-code">; 
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">txt</span><span class="hl-code"> = </span><span class="hl-identifier">str</span><span class="hl-code">.</span><span class="hl-identifier">replace</span><span class="hl-brackets">(</span><span class="hl-quotes">"</span><span class="hl-string">Microsoft</span><span class="hl-quotes">"</span><span class="hl-code">,</span><span class="hl-quotes">"</span><span class="hl-string">Runoob</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">;</span></div>
</div>
<br>
<a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_string_replace" target="_blank">尝试一下 »</a>
</div>
<br>
<hr>

<h2>你注意到了吗？</h2>

<br>


<table class="lamp"><tbody><tr>
<th style="width: 34px;"><img style="width: 32px; height: 32px;" alt="Note" src="./JavaScript 正则表达式 _ 菜鸟教程_files/lamp.jpg"></th>
<td>正则表达式参数可用在以上方法中 (替代字符串参数)。<br>
正则表达式使得搜索功能更加强大(如实例中不区分大小写)。</td>
</tr></tbody></table>
<br>
<hr>
<h2>正则表达式修饰符</h2>
<p><strong>修饰符</strong> 可以在全局搜索中不区分大小写:</p>

<table class="reference">
  <tbody><tr>
    <th style="width: 22%;">修饰符</th>
    <th>描述</th>
  </tr>
  <tr>
    <td>i</td>
    <td>执行对大小写不敏感的匹配。</td>
  </tr>
  <tr>
    <td>g</td>
    <td>执行全局匹配（查找所有匹配而非在找到第一个匹配后停止）。</td>
  </tr>
	<tr>
    <td>m</td>
    <td>执行多行匹配。</td>
  </tr>
</tbody></table>

<br>

<hr>

<h2>正则表达式模式</h2>
<p>方括号用于查找某个范围内的字符：</p>
<table class="reference">
  <tbody><tr>
    <th style="width: 22%;">表达式</th>
    <th>描述</th>
  </tr>
	<tr>
    <td>[abc]</td>
    <td>查找方括号之间的任何字符。</td>
	</tr><tr>
    <td>[0-9]</td>
    <td>查找任何从 0 至 9 的数字。</td>
  	</tr><tr>
    <td>(x|y)</td>
    <td>查找任何以 | 分隔的选项。 </td>
  </tr>
	</tbody></table>

<p>元字符是拥有特殊含义的字符：</p>
<table class="reference">
<tbody><tr>
    <th style="width: 22%;">元字符</th>
    <th>描述</th>
</tr>
<tr>
    <td>\d</td>
    <td>查找数字。</td>
</tr>
<tr>
    <td>\s</td>
    <td>查找空白字符。</td>
</tr>
<tr>
    <td>\b</td>
    <td>匹配单词边界。</td>
</tr>
<tr>
    <td>\uxxxx</td>
    <td>查找以十六进制数 xxxx 规定的 Unicode 字符。</td>
</tr>
</tbody></table>

<p>量词:</p>
<table class="reference">
  <tbody><tr>
    <th style="width: 22%;">量词</th>
    <th>描述</th>
  </tr>
	<tr>
    <td>n+</td>
    <td>匹配任何包含至少一个 <em>n</em> 的字符串。</td>
  </tr>
	<tr>
    <td>n*</td>
    <td>匹配任何包含零个或多个 <em>n</em> 的字符串。 </td>
  </tr>
	<tr>
    <td>n?</td>
    <td>匹配任何包含零个或一个 <em>n</em> 的字符串。</td>
  </tr>
</tbody></table>
<br>

<hr>
<h2>使用 RegExp 对象</h2>
<p>在 JavaScript 中，RegExp 对象是一个预定义了属性和方法的正则表达式对象。 </p>

<hr>
<h2>使用 test()</h2>
<p> test() 方法是一个正则表达式方法。</p>
<p>test() 方法用于检测一个字符串是否匹配某个模式，如果字符串中含有匹配的文本，则返回 true，否则返回 false。</p>
<p>以下实例用于搜索字符串中的字符 "e"：</p>

<div class="example">
<h2 class="example">实例</h2>
<div class="example_code">
<span class="highELE">var</span> patt = /e/;<br>
patt.test(<span class="highVAL">"The best things in life are free!"</span>);
</div>
<p>字符串中含有 "e"，所以该实例输出为：</p>
<div class="example_code">
true
</div>
<br><a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_regexp_test" target="_blank">尝试一下 »</a>
<p>你可以不用设置正则表达式的变量，以上两行代码可以合并为一行： </p>
<div class="example_code">
/e/.test(<span class="highVAL">"The best things in life are free!"</span>)
</div>
</div>
<br>
<hr>

<h2>使用 exec()</h2>
<p>exec() 方法是一个正则表达式方法。</p>
<p>exec() 方法用于检索字符串中的正则表达式的匹配。</p>
<p>该函数返回一个数组，其中存放匹配的结果。如果未找到匹配，则返回值为 null。</p>
<p>以下实例用于搜索字符串中的字母 "e":</p>

<div class="example">
<h2 class="example">Example 1</h2>
<div class="example_code">
	/e/.exec(<span class="highVAL">"The best things in life are free!"</span>);
</div>
<p>字符串中含有 "e"，所以该实例输出为:</p>
<div class="example_code">
e</div>
<br><a class="tryitbtn" href="https://www.runoob.com/try/tryit.php?filename=tryjs_regexp_exec" target="_blank">尝试一下 »</a>
</div>
<hr>
<h2>更多实例</h2>
<ul>
	<li><p><a href="https://c.runoob.com/codedemo/3527" target="_blank">JS 判断输入字符串是否为数字、字母、下划线组成</a></p></li>
	<li><p><a href="https://c.runoob.com/codedemo/3526" target="_blank">JS 判断输入字符串是否全部为字母</a></p></li>
	<li><p><a href="https://c.runoob.com/codedemo/3525" target="_blank">JS 判断输入字符串是否全部为数字</a></p></li>
</ul>

<hr>

<h2>完整的 RegExp 参考手册</h2>
<p>完整的 RegExp 对象参考手册，请参考我们的 <a href="https://www.runoob.com/jsref/jsref-obj-regexp.html"> 
JavaScript RegExp 参考手册</a>。</p>
<p>该参考手册包含了所有 RegExp 对象的方法和属性。</p>
			<!-- 其他扩展 -->
						
			</div>
			
		</div>
		
		<div class="previous-next-links">
			<div class="previous-design-link"><a href="https://www.runoob.com/js/js-type-conversion.html"><i style="font-size:16px;" class="fa fa-arrow-left" aria-hidden="true"></i></a> <a href="https://www.runoob.com/js/js-type-conversion.html" rel="prev" title="JavaScript 类型转换">JavaScript 类型转换</a> </div>
			<div class="next-design-link"><a href="https://www.runoob.com/js/js-errors.html" rel="next" title="JavaScript 错误 – Throw、Try 和 Catch">JavaScript 错误 – Throw、Try 和 Catch</a> <a href="https://www.runoob.com/js/js-errors.html"><i style="font-size:16px;" class="fa fa-arrow-right" aria-hidden="true"></i></a></div>
		</div>
		<!-- 笔记列表 -->
		<style>
.wrapper {
  /*text-transform: uppercase; */
  background: #ececec;
  color: #555;
  cursor: help;
  font-family: "Gill Sans", Impact, sans-serif;
  font-size: 20px;
  position: relative;
  text-align: center;
  width: 200px;
  -webkit-transform: translateZ(0); /* webkit flicker fix */
  -webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}

.wrapper .tooltip {
  white-space: nowrap;
  font-size: 14px;
  text-align: left;
  background: #96b97d;
  bottom: 100%;
  color: #fff;
  display: block;
  left: -25px;
  margin-bottom: 15px;
  opacity: 0;
  padding: 14px;
  pointer-events: none;
  position: absolute;
  
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
.tooltip a {
	color:#fff;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  

/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
  border-top: solid #96b97d 10px;
  bottom: -10px;
  content: " ";
  height: 0;
  left: 20%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
.wrapper .tooltip1 {
	margin-left: 50px;
	padding-top: 0px;
}
.wrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}

/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
  display: none;
}

.lte8 .wrapper:hover .tooltip {
  display: block;
}

</style>

<div class="title" id="comments">
	<h2 class="">
    <div class="altblock">
		    	<i style="font-size:28px;margin-top: 8px;" class="fa fa-pencil-square-o" aria-hidden="true"></i>
    	    </div>
    <span class="mw-headline" id="qa_headline">1  篇笔记</span>
	<span class="mw-headline" id="user_add_note" style="float:right;line-height: 62px;padding-right: 14px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>  写笔记</span>
    </h2>
</div>
<div id="postcomments">
	<ol class="commentlist">
		<li class="comment even thread-even depth-1" id="comment-10682"><span class="comt-f">#1</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;qq1056125478</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;105***5478@qq.com</p></div></div><div class="comt-main" id="div-comment-10682"><p>正则表达式表单验证实例：</p>
<pre class="prettyprint prettyprinted" style=""><span class="com">/*是否带有小数*/</span><span class="pln">
</span><span class="kwd">function</span><span class="pln">    isDecimal</span><span class="pun">(</span><span class="pln">strValue </span><span class="pun">)</span><span class="pln">  </span><span class="pun">{</span><span class="pln">  
   </span><span class="kwd">var</span><span class="pln">  objRegExp</span><span class="pun">=</span><span class="pln"> </span><span class="str">/^\d+\.\d+$/</span><span class="pun">;</span><span class="pln">
   </span><span class="kwd">return</span><span class="pln">  objRegExp</span><span class="pun">.</span><span class="pln">test</span><span class="pun">(</span><span class="pln">strValue</span><span class="pun">);</span><span class="pln">  
</span><span class="pun">}</span><span class="pln">  

</span><span class="com">/*校验是否中文名称组成 */</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> ischina</span><span class="pun">(</span><span class="pln">str</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">var</span><span class="pln"> reg</span><span class="pun">=</span><span class="str">/^[\u4E00-\u9FA5]{2,4}$/</span><span class="pun">;</span><span class="pln">   </span><span class="com">/*定义验证表达式*/</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">return</span><span class="pln"> reg</span><span class="pun">.</span><span class="pln">test</span><span class="pun">(</span><span class="pln">str</span><span class="pun">);</span><span class="pln">     </span><span class="com">/*进行验证*/</span><span class="pln">
</span><span class="pun">}</span><span class="pln">

</span><span class="com">/*校验是否全由8位数字组成 */</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> isStudentNo</span><span class="pun">(</span><span class="pln">str</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">var</span><span class="pln"> reg</span><span class="pun">=</span><span class="str">/^[0-9]{8}$/</span><span class="pun">;</span><span class="pln">   </span><span class="com">/*定义验证表达式*/</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">return</span><span class="pln"> reg</span><span class="pun">.</span><span class="pln">test</span><span class="pun">(</span><span class="pln">str</span><span class="pun">);</span><span class="pln">     </span><span class="com">/*进行验证*/</span><span class="pln">
</span><span class="pun">}</span><span class="pln">

</span><span class="com">/*校验电话码格式 */</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> isTelCode</span><span class="pun">(</span><span class="pln">str</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">var</span><span class="pln"> reg</span><span class="pun">=</span><span class="pln"> </span><span class="str">/^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/</span><span class="pun">;</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">return</span><span class="pln"> reg</span><span class="pun">.</span><span class="pln">test</span><span class="pun">(</span><span class="pln">str</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">

</span><span class="com">/*校验邮件地址是否合法 */</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> </span><span class="typ">IsEmail</span><span class="pun">(</span><span class="pln">str</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">var</span><span class="pln"> reg</span><span class="pun">=</span><span class="str">/^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/</span><span class="pun">;</span><span class="pln">
&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kwd">return</span><span class="pln"> reg</span><span class="pun">.</span><span class="pln">test</span><span class="pun">(</span><span class="pln">str</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span></pre><p>
<a target="_blank" href="https://c.runoob.com/codedemo/2873" class="tryitbtn" rel="nofollow">尝试一下 »</a></p><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">qq1056125478</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;qq1056125478</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;105***5478@qq.com</p></div></span>2年前 (2017-04-03)</div></div></li><!-- #comment-## -->
	</ol>
	<div class="pagenav">
			</div>
</div>

<div id="respond" class="no_webshot"> 
		<div class="comment-signarea" style="display:none; padding: 20px 20px;"> 
	<h3 class="text-muted" id="share_code" style="color: #799961;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 点我分享笔记</h3>
	<!--
	<p style="font-size:14px;">笔记需要是本篇文章的内容扩展！</p><br>
	<p style="font-size:12px;"><a href="//www.runoob.com/tougao" target="_blank">文章投稿，可点击这里</a></p>
	<p style="font-size:14px;"><a href="/w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>
		<h3 class="text-muted"><i class="fa fa-info-circle" aria-hidden="true"></i> 分享笔记前必须<a href="javascript:;" class="runoob-pop">登录</a>！</h3>
		<p><a href="/w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>-->
	</div>
		
	<form action="https://www.runoob.com/wp-content/themes/runoob/option/addnote.php" method="post" id="commentform" style="display:none;"><div id="comment-status" style="display:none;"></div>
		<div class="comt">
			<div class="comt-title">
				<i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i>				<p><a id="cancel-comment-reply-link" href="javascript:;">取消</a></p>
			</div>
			<div class="comt-box">
			<div class="simditor">
  <div class="simditor-wrapper"><div class="simditor-toolbar" style="top: 0px; width: 0px; left: 0px;"><ul><li><a tabindex="-1" unselectable="on" class="toolbar-item toolbar-item-bold" href="javascript:;" title="加粗文字 ( Ctrl + b )"><span class="simditor-icon simditor-icon-bold"></span></a></li><li><a tabindex="-1" unselectable="on" class="toolbar-item toolbar-item-code" href="javascript:;" title="插入代码"><span class="simditor-icon simditor-icon-code"></span></a></li><li><a tabindex="-1" unselectable="on" class="toolbar-item toolbar-item-ul" href="javascript:;" title="无序列表 ( Ctrl + . )"><span class="simditor-icon simditor-icon-list-ul"></span></a></li><li><a tabindex="-1" unselectable="on" class="toolbar-item toolbar-item-ol" href="javascript:;" title="有序列表 ( ctrl + / )"><span class="simditor-icon simditor-icon-list-ol"></span></a></li><li><a tabindex="-1" unselectable="on" class="toolbar-item toolbar-item-image" href="javascript:;" title="插入图片"><span class="simditor-icon simditor-icon-picture-o"></span></a></li></ul></div>
    <div class="simditor-placeholder" style="display: block; top: 1px;">写笔记...</div>
    <div class="simditor-body" contenteditable="true"><p><br></p></div>
  <div id="mded"></div></div>
<div class="simditor-popover code-popover"><div class="code-settings">
  <div class="settings-field">
    <select class="select-lang">
      <option value="-1">选择程序语言</option>
    <option value="bash">Bash</option><option value="c++">C++</option><option value="cs">C#</option><option value="css">CSS</option><option value="erlang">Erlang</option><option value="less">Less</option><option value="sass">Sass</option><option value="diff">Diff</option><option value="coffeescript">CoffeeScript</option><option value="html">HTML,XML</option><option value="json">JSON</option><option value="java">Java</option><option value="js">JavaScript</option><option value="markdown">Markdown</option><option value="oc">Objective C</option><option value="php">PHP</option><option value="parl">Perl</option><option value="python">Python</option><option value="ruby">Ruby</option><option value="sql">SQL</option></select>
  </div>
</div></div><div class="simditor-popover image-popover"><div class="link-settings">
  <div class="settings-field">
    <label>图片地址</label>
    <input class="image-src" type="text" tabindex="1">
    
  </div>
  <div class="settings-field">
    <label>图片描述</label>
    <input class="image-alt" id="image-alt" type="text" tabindex="1">
  </div>
  <div class="settings-field">
    <label>图片尺寸</label>
    <input class="image-size" id="image-width" type="text" tabindex="2">
    <span class="times">×</span>
    <input class="image-size" id="image-height" type="text" tabindex="3">
    <a class="btn-restore" href="javascript:;" title="还原图片尺寸" tabindex="-1">
      <span class="simditor-icon simditor-icon-undo"></span>
    </a>
  </div>
</div></div></div>
			
				<div class="comt-ctrl">
					<div class="comt-tips"><input type="hidden" name="comment_post_ID" value="10979" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</div>
					<button type="submit" name="submit" id="submit" tabindex="5"><i class="fa fa-pencil" aria-hidden="true"></i> 分享笔记</button>
				</div>
			</div>
		
				
					<div class="comt-comterinfo"> 
						<ul id="comment-author-info">
							<li class="form-inline"><label class="hide" for="author">昵称</label><input class="ipt" type="text" name="author" id="author" value="" tabindex="2" placeholder="昵称"><span class="text-muted">昵称 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="email">邮箱</label><input class="ipt" type="text" name="email" id="email" value="" tabindex="3" placeholder="邮箱"><span class="text-muted">邮箱 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="url">引用地址</label><input class="ipt" type="text" name="url" id="url" value="" tabindex="4" placeholder="引用地址"><span class="text-muted">引用地址</span></li>
						</ul>
					</div>
				
			
		</div>

	</form>
	</div>
<script type="text/javascript">
$(function() {
	//初始化编辑器
	
	var editor = new Simditor({
	  textarea: $('#mded'),
	  placeholder: '写笔记...',
	  upload:false,
	 // upload: {url:'/api/comment_upload_file.php',params: null,fileKey: 'upload_file',connectionCount: 1,leaveConfirm: '文件正在上传，您确定离开?'},
	  defaultImage: 'http://www.runoob.com/images/logo.png',
	  codeLanguages: '',
	  toolbar: [  'bold','code','ul','ol','image' ]
	});
	editor.on('selectionchanged', function() {
		$(".code-popover").hide();
	});

	// 提交数据
	$("#share_code").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		
	});
	$("#user_add_note").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		$('html, body').animate({
       	    scrollTop: $("#respond").offset().top
    	}, 200);
	});

	// 提交笔记
	var commentform=$('#commentform');
	commentform.prepend('<div id="comment-status" style="display:none;" ></div>');
	var statusdiv=$('#comment-status');
	
	commentform.submit(function(e){
		e.preventDefault();
		var noteContent = editor.getValue();
		// console.log(noteContent);
		noteContent = noteContent.replace(/<pre><code>/g,"<pre>");
		noteContent = noteContent.replace(/<\/code><\/pre>/g,"</pre>");
		
		// 系列化表单数据
		var comment_parent = 0;
		var is_user_logged_in = $("#is_user_logged_in").val();
		var comment_post_ID =  10979;
		var _wp_unfiltered_html_comment = $("#_wp_unfiltered_html_comment").val();
		var comment = noteContent;
		var author = $("#author").val();
		var url = $("#url").val();
		var email = $("#email").val();
		if(isBlank(author) && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入昵称！</p>').show();
		} else if(isBlank(email)  && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入邮箱！</p>').show();
		} else {
			// var formdata=commentform.serialize() + "&comment=" + noteContent ;
			// 添加状态信息
			statusdiv.html('<p>Processing...</p>').show();
			// 获取表单提交地址
			var formurl=commentform.attr('action');
			
			// 异步提交
			$.ajax({
					type: 'post',
					url: formurl,
					dataType:'json',
					data: {"comment_parent":comment_parent,"comment_post_ID":comment_post_ID, "_wp_unfiltered_html_comment":_wp_unfiltered_html_comment,"comment":comment,"url":url, "email":email,"author":author},
					error: function(XMLHttpRequest, textStatus, errorThrown){
					statusdiv.html('<p class="ajax-error" >数据不完整或表单提交太快了！</p>').show();
				},
				success: function(data, textStatus){
					if(data.errorno=="0") {
						$("#submit").prop('disabled', true);
						statusdiv.html('<p class="ajax-success" >笔记已提交审核，感谢分享笔记！</p>').show();
						alert('笔记已提交审核，感谢分享笔记！');
					}else{
						statusdiv.html('<p class="ajax-error" >'+data.msg+'</p>').show();
					}
					commentform.find('textarea[name=comment]').val('');
				}
			});
			setTimeout(function(){
		        $("#submit").prop('disabled', false);
		    }, 10*1000);
		}
		return false;

	});
	
});
function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}
</script>

<link rel="stylesheet" href="./JavaScript 正则表达式 _ 菜鸟教程_files/qa.css">
<link rel="stylesheet" type="text/css" href="./JavaScript 正则表达式 _ 菜鸟教程_files/simditor.min.css">
<script type="text/javascript" src="./JavaScript 正则表达式 _ 菜鸟教程_files/module.js.下载"></script>
<script type="text/javascript" src="./JavaScript 正则表达式 _ 菜鸟教程_files/hotkeys.js.下载"></script>
<script type="text/javascript" src="./JavaScript 正则表达式 _ 菜鸟教程_files/uploader.js.下载"></script>
<script type="text/javascript" src="./JavaScript 正则表达式 _ 菜鸟教程_files/simditor.min.js.下载"></script>		<div class="sidebar-box ad-box ad-box-large">
				<div id="ad-336280">
		<script async="" src="./JavaScript 正则表达式 _ 菜鸟教程_files/f(5).txt"></script>
		<!-- 移动版 自动调整 -->
		<ins class="adsbygoogle" style="display: block; height: 79px;" data-ad-client="ca-pub-5751451760833794" data-ad-slot="1691338467" data-ad-format="auto" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display: inline-table; border: none; height: 79px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 855px; background-color: transparent;"><ins id="aswift_0_anchor" style="display: block; border: none; height: 79px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 855px; background-color: transparent; overflow: hidden;"><iframe width="855" height="79" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left: 0px; position: absolute; top: 0px; border: 0px; width: 855px; height: 79px;" src="./JavaScript 正则表达式 _ 菜鸟教程_files/saved_resource(1).html"></iframe></ins></ins></ins>
		<script>
		(adsbygoogle = window.adsbygoogle || []).push({});
		</script>
		</div>
				</div>
		
	</div>
</div>
	

<!-- 右边栏 -->
<div class="fivecol last right-column">
<!--
	<div class="tab tab-light-blue" style="text-align: center;">关注微信</div>
	<div class="sidebar-box">
		<a href="http://m.runoob.com/" target="_blank"> <img src="http://www.runoob.com/wp-content/themes/w3cschool.cc/assets/img/qrcode.jpg" alt="移动版"> </a>
		<div class="qqinfo">
		 <a target="_blank" href="http://jq.qq.com/?_wv=1027&k=dOwwKN" id="qqhref">
		<img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="菜鸟家族" title="菜鸟家族"></a>
		<span>(群号：<span id="qqid">365967760</span>)</span>
		</div>
		
	</div>
	-->
<style>
.sidebar-tree .double-li {
	width:300px;
}
.sidebar-tree .double-li li {
    width: 44%;
    line-height: 1.5em;
    border-bottom: 1px solid #ccc;
    float: left;
    display: inline;
}
</style>

	
		<div class="sidebar-box ad-box ad-box-large">
		<div class="sidebar-box advertise-here" style="margin: 0 auto;">
			<a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;"> <i class="fa fa-list" aria-hidden="true"></i> 分类导航</a>
		</div>
	<div class="sidebar-box sidebar-cate">
		
		<div class="sidebar-tree">
			<ul><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> HTML / CSS</a><ul class="double-li"><li><a title="HTML 教程" href="https://www.runoob.com/html/html-tutorial.html">HTML 教程</a></li><li><a title="HTML5 教程" href="https://www.runoob.com/html/html5-intro.html">HTML5 教程</a></li><li><a title="CSS 教程" href="https://www.runoob.com/css/css-tutorial.html">CSS 教程</a></li><li><a title="CSS3 教程" href="https://www.runoob.com/css3/css3-tutorial.html">CSS3 教程</a></li><li><a title="Bootstrap3 教程" href="https://www.runoob.com/bootstrap/bootstrap-tutorial.html">Bootstrap3 教程</a></li><li><a title="Bootstrap4 教程" href="https://www.runoob.com/bootstrap4/bootstrap4-tutorial.html">Bootstrap4 教程</a></li><li><a title="Font Awesome 教程" href="https://www.runoob.com/font-awesome/fontawesome-tutorial.html">Font Awesome 教程</a></li><li><a title="Foundation 教程" href="https://www.runoob.com/foundation/foundation-tutorial.html">Foundation 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> JavaScript</a><ul class="double-li"><li><a title="JavaScript 教程" href="https://www.runoob.com/js/js-tutorial.html">JavaScript 教程</a></li><li><a title="HTML DOM 教程" href="https://www.runoob.com/htmldom/htmldom-tutorial.html">HTML DOM 教程</a></li><li><a title="jQuery 教程" href="https://www.runoob.com/jquery/jquery-tutorial.html">jQuery 教程</a></li><li><a title="AngularJS 教程" href="https://www.runoob.com/angularjs/angularjs-tutorial.html">AngularJS 教程</a></li><li><a title="AngularJS2 教程" href="https://www.runoob.com/angularjs2/angularjs2-tutorial.html">AngularJS2 教程</a></li><li><a title="Vue.js 教程" href="https://www.runoob.com/vue2/vue-tutorial.html">Vue.js 教程</a></li><li><a title="React 教程" href="https://www.runoob.com/react/react-tutorial.html">React 教程</a></li><li><a title="TypeScript 教程" href="https://www.runoob.com/typescript/ts-tutorial.html">TypeScript 教程</a></li><li><a title="jQuery UI 教程" href="https://www.runoob.com/jqueryui/jqueryui-tutorial.html">jQuery UI 教程</a></li><li><a title="jQuery EasyUI 教程" href="https://www.runoob.com/jeasyui/jqueryeasyui-tutorial.html">jQuery EasyUI 教程</a></li><li><a title="Node.js 教程" href="https://www.runoob.com/nodejs/nodejs-tutorial.html">Node.js 教程</a></li><li><a title="AJAX 教程" href="https://www.runoob.com/ajax/ajax-tutorial.html">AJAX 教程</a></li><li><a title="JSON 教程" href="https://www.runoob.com/json/json-tutorial.html">JSON 教程</a></li><li><a title="Highcharts 教程" href="https://www.runoob.com/highcharts/highcharts-tutorial.html">Highcharts 教程</a></li><li><a title="Google 地图 教程" href="https://www.runoob.com/googleapi/google-maps-basic.html">Google 地图 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 服务端</a><ul class="double-li"><li><a title="PHP 教程" href="https://www.runoob.com/php/php-tutorial.html">PHP 教程</a></li><li><a title="Python 教程" href="https://www.runoob.com/python/python-tutorial.html">Python 教程</a></li><li><a title="Python3 教程" href="https://www.runoob.com/python3/python3-tutorial.html">Python3 教程</a></li><li><a title="Django 教程" href="https://www.runoob.com/django/django-tutorial.html">Django 教程</a></li><li><a title="Linux 教程" href="https://www.runoob.com/linux/linux-tutorial.html">Linux 教程</a></li><li><a title="Docker 教程" href="https://www.runoob.com/docker/docker-tutorial.html">Docker 教程</a></li><li><a title="Ruby 教程" href="https://www.runoob.com/ruby/ruby-tutorial.html">Ruby 教程</a></li><li><a title="Java 教程" href="https://www.runoob.com/java/java-tutorial.html">Java 教程</a></li><li><a title="C 教程" href="https://www.runoob.com/c/c-tutorial.html">C 教程</a></li><li><a title="C++ 教程" href="https://www.runoob.com/cplusplus/cpp-tutorial.html">C++ 教程</a></li><li><a title="Perl 教程" href="https://www.runoob.com/perl/perl-tutorial.html">Perl 教程</a></li><li><a title="Servlet 教程" href="https://www.runoob.com/servlet/servlet-tutorial.html">Servlet 教程</a></li><li><a title="JSP 教程" href="https://www.runoob.com/jsp/jsp-tutorial.html">JSP 教程</a></li><li><a title="Lua 教程" href="https://www.runoob.com/lua/lua-tutorial.html">Lua 教程</a></li><li><a title="Scala 教程" href="https://www.runoob.com/scala/scala-tutorial.html">Scala 教程</a></li><li><a title="Go 教程" href="https://www.runoob.com/go/go-tutorial.html">Go 教程</a></li><li><a title="设计模式" href="https://www.runoob.com/design-pattern/design-pattern-tutorial.html">设计模式</a></li><li><a title="正则表达式" href="https://www.runoob.com/regexp/regexp-tutorial.html">正则表达式</a></li><li><a title="Maven 教程" href="https://www.runoob.com/maven/maven-tutorial.html">Maven 教程</a></li><li><a title="NumPy 教程" href="https://www.runoob.com/numpy/numpy-tutorial.html">NumPy 教程</a></li><li><a title="ASP 教程" href="https://www.runoob.com/asp/asp-tutorial.html">ASP 教程</a></li><li><a title="AppML 教程" href="https://www.runoob.com/appml/appml-tutorial.html">AppML 教程</a></li><li><a title="VBScript 教程" href="https://www.runoob.com/vbscript/vbscript-tutorial.html">VBScript 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 数据库</a><ul class="double-li"><li><a title="SQL 教程" href="https://www.runoob.com/sql/sql-tutorial.html">SQL 教程</a></li><li><a title="Mysql 教程" href="https://www.runoob.com/mysql/mysql-tutorial.html">Mysql 教程</a></li><li><a title="SQLite 教程" href="https://www.runoob.com/sqlite/sqlite-tutorial.html">SQLite 教程</a></li><li><a title="MongoDB 教程" href="https://www.runoob.com/mongodb/mongodb-tutorial.html">MongoDB 教程</a></li><li><a title="Redis 教程" href="https://www.runoob.com/redis/redis-tutorial.html">Redis 教程</a></li><li><a title="Memcached 教程" href="https://www.runoob.com/Memcached/Memcached-tutorial.html">Memcached 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 移动端</a><ul class="double-li"><li><a title="Android 教程" href="https://www.runoob.com/w3cnote/android-tutorial-intro.html">Android 教程</a></li><li><a title="Swift 教程" href="https://www.runoob.com/swift/swift-tutorial.html">Swift 教程</a></li><li><a title="jQuery Mobile 教程" href="https://www.runoob.com/jquerymobile/jquerymobile-tutorial.html">jQuery Mobile 教程</a></li><li><a title="ionic 教程" href="https://www.runoob.com/ionic/ionic-tutorial.html">ionic 教程</a></li><li><a title="Kotlin 教程" href="https://www.runoob.com/kotlin/kotlin-tutorial.html">Kotlin 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> XML 教程</a><ul class="double-li"><li><a title="XML 教程" href="https://www.runoob.com/xml/xml-tutorial.html">XML 教程</a></li><li><a title="DTD 教程" href="https://www.runoob.com/dtd/dtd-tutorial.html">DTD 教程</a></li><li><a title="XML DOM 教程" href="https://www.runoob.com/dom/dom-tutorial.html">XML DOM 教程</a></li><li><a title="XSLT 教程" href="https://www.runoob.com/xsl/xsl-tutorial.html">XSLT 教程</a></li><li><a title="XPath 教程" href="https://www.runoob.com/xpath/xpath-tutorial.html">XPath 教程</a></li><li><a title="XQuery 教程" href="https://www.runoob.com/xquery/xquery-tutorial.html">XQuery 教程</a></li><li><a title="XLink 教程" href="https://www.runoob.com/xlink/xlink-tutorial.html">XLink 教程</a></li><li><a title="XPointer 教程" href="https://www.runoob.com/xlink/xlink-tutorial.html">XPointer 教程</a></li><li><a title="XML Schema 教程" href="https://www.runoob.com/schema/schema-tutorial.html">XML Schema 教程</a></li><li><a title="XSL-FO 教程" href="https://www.runoob.com/xslfo/xslfo-tutorial.html">XSL-FO 教程</a></li><li><a title="SVG 教程" href="https://www.runoob.com/svg/svg-tutorial.html">SVG 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> ASP.NET</a><ul class="double-li"><li><a title="ASP.NET 教程" href="https://www.runoob.com/aspnet/aspnet-tutorial.html">ASP.NET 教程</a></li><li><a title="C# 教程" href="https://www.runoob.com/csharp/csharp-tutorial.html">C# 教程</a></li><li><a title="Web Pages 教程" href="https://www.runoob.com/aspnet/webpages-intro.html">Web Pages 教程</a></li><li><a title="Razor 教程" href="https://www.runoob.com/aspnet/razor-intro.html">Razor 教程</a></li><li><a title="MVC 教程" href="https://www.runoob.com/aspnet/mvc-intro.html">MVC 教程</a></li><li><a title="Web Forms 教程" href="https://www.runoob.com/aspnet/aspnet-intro.html">Web Forms 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> Web Service</a><ul class="double-li"><li><a title="Web Service 教程" href="https://www.runoob.com/webservices/webservices-tutorial.html">Web Service 教程</a></li><li><a title="WSDL 教程" href="https://www.runoob.com/wsdl/wsdl-tutorial.html">WSDL 教程</a></li><li><a title="SOAP 教程" href="https://www.runoob.com/soap/soap-tutorial.html">SOAP 教程</a></li><li><a title="RSS 教程" href="https://www.runoob.com/rss/rss-tutorial.html">RSS 教程</a></li><li><a title="RDF 教程" href="https://www.runoob.com/rdf/rdf-tutorial.html">RDF 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 开发工具</a><ul class="double-li"><li><a title="Eclipse 教程" href="https://www.runoob.com/eclipse/eclipse-tutorial.html">Eclipse 教程</a></li><li><a title="Git 教程" href="https://www.runoob.com/git/git-tutorial.html">Git 教程</a></li><li><a title="Svn 教程" href="https://www.runoob.com/svn/svn-tutorial.html">Svn 教程</a></li><li><a title="Markdown 教程" href="https://www.runoob.com/markdown/md-tutorial.html">Markdown 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 网站建设</a><ul class="double-li"><li><a title="HTTP 教程" href="https://www.runoob.com/http/http-tutorial.html">HTTP 教程</a></li><li><a title="网站建设指南" href="https://www.runoob.com/web/web-buildingprimer.html">网站建设指南</a></li><li><a title="浏览器信息" href="https://www.runoob.com/browsers/browser-information.html">浏览器信息</a></li><li><a title="网站主机教程" href="https://www.runoob.com/hosting/hosting-tutorial.html">网站主机教程</a></li><li><a title="TCP/IP 教程" href="https://www.runoob.com/tcpip/tcpip-tutorial.html">TCP/IP 教程</a></li><li><a title="W3C 教程" href="https://www.runoob.com/w3c/w3c-tutorial.html">W3C 教程</a></li><li><a title="网站品质" href="https://www.runoob.com/quality/quality-tutorial.html">网站品质</a></li></ul></li></ul>			</div>
	
	</div>
	</div>
	<br>
	
	<div class="sidebar-box ad-box ad-box-large">
		<div class="sidebar-box advertise-here">
			<a href="javascript:void(0);">Advertisement</a>
		</div>
		<div class="ad-600160" id="sidebar-right-ads">
		<a data-tt="1976058" onclick="_hmt.push([&#39;_trackEvent&#39;, &#39;广告&#39;, &#39;click&#39;, &#39;ad7&#39;])" href="https://www.bat888.cn/caibird/" target="_blank"><img src="./JavaScript 正则表达式 _ 菜鸟教程_files/jxjy-ad.jpg"><p></p></a>		</div>
	</div>
</div></div>

</div>

<script>
var aid = 10979;
function coll() {
	$.post( '/wp-content/themes/runoob/option/user/userinfo.php', {aid:aid, action:"collarticle", opt:'add'},function( data ) {
		if(data.error==0) {
			$("#content").find("h1:first").find("a").attr("href","javascript:void(0);");
			$("#content").find("h1:first").find("img").attr("src","http://www.runoob.com/wp-content/themes/runoob/assets/img/coll2.png").css({width:32+"px",height:32+"px"});
		}
		alert(data.msg);
	},'json');
}
</script>


<!-- 反馈对话框开始 -->
<script src="./JavaScript 正则表达式 _ 菜鸟教程_files/feedback.js.下载"></script>
<link rel="stylesheet" href="./JavaScript 正则表达式 _ 菜鸟教程_files/feedback.css">
<script type="text/javascript">
$.feedback({
    ajaxURL: '/feedback/runoob_feedback.php',
    html2canvasURL: '/wp-content/themes/runoob/assets/feedback/stable/2.0/html2canvas.js'
});
</script><button class="feedback-btn feedback-btn-gray" style="display: inline-block;">反馈/建议</button>
<!-- 反馈对话框结束 -->
<button class="feedback-btn feedback-btn-gray" style="display: inline-block;">反馈/建议</button>
<!-- 底部 -->


<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       ·<a target="_blank" href="https://www.runoob.com/jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       ·<a target="_blank" href="https://www.runoob.com/java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&amp;工具
      </dt>
      <dd>
       · <a target="_blank" href="https://www.runoob.com/charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       · <a target="_blank" href="https://www.runoob.com/tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       · <a target="_blank" href="https://www.runoob.com/tags/ref-entities.html">HTML ISO-8859-1</a>
      </dd> 
      <dd>
       · <a target="_blank" href="https://www.runoob.com/tags/html-symbols.html">HTML 实体符号</a>
      </dd>
      <dd>
       · <a target="_blank" href="https://www.runoob.com/tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       · <a target="_blank" href="https://c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-distinct.html" title="PostgreSQL DISTINCT 关键字">PostgreSQL DIST...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-having.html" title="PostgreSQL HAVING 子句">PostgreSQL HAVI...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-with.html" title="PostgreSQL WITH 子句">PostgreSQL WITH...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-group-by.html" title="PostgreSQL GROUP BY 语句">PostgreSQL GROU...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-order-by.html" title="PostgreSQL ORDER BY  语句">PostgreSQL ORDE...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-limit.html" title="PostgreSQL LIMIT 子句">PostgreSQL LIMI...</a>
      </dd>
              <dd>
       ·
      <a href="http://www.runoob.com/postgresql/postgresql-like.html" title="PostgreSQL LIKE 子句">PostgreSQL LIKE...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       ·
       <a target="_blank" href="https://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=ssbDyoOAgfLU3crf09venNHd3w" rel="external nofollow">意见反馈</a>
      </dd>
         <!--
      <dd>
       &middot;
      <a target="_blank" href="//www.runoob.com/w3cnote/knowledge-start.html">支持我们
     </a>
     </dd>
     -->
      <dd>
       ·
      <a class="wxpopup" onclick="popFunction()">合作联系
       <span class="popuptext" id="myPopup">微信(注明来意)：<strong>centos5</strong></span>
      </a>
      </dd>
      <dd>
       ·
      <a target="_blank" href="https://www.runoob.com/disclaimer">免责声明</a>
       </dd>
       <!--
       <dd style="display: block;">
       &middot;
      <a href="javascript:void(0)" onclick="dashangToggle()" style="font-weight:bold;color:#f00;" title="打赏，支持一下">打赏一下</a>
       </dd>
     -->
      <dd>
       ·
       <a target="_blank" href="https://www.runoob.com/aboutus">关于我们</a>
       </dd>
      <dd>
       ·
      <a target="_blank" href="https://www.runoob.com/archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
            <img width="128" height="128" src="./JavaScript 正则表达式 _ 菜鸟教程_files/qrcode.png">
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright © 2013-2019    <strong><a href="https://www.runoob.com/" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="https://www.runoob.com/" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：闽ICP备15012807号-1
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部" style="display: inline-block;"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode" href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="" href="javascript:void(0)" title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="./JavaScript 正则表达式 _ 菜鸟教程_files/qrcode.png"></div> 
    </div>
  </div>

  <div class="hide_box"></div>
    <div class="shang_box">
      <a class="shang_close" href="javascript:void(0)" onclick="dashangToggle()" title="关闭"><img src="./JavaScript 正则表达式 _ 菜鸟教程_files/close.jpg" alt="取消"></a>
       
      <div class="shang_tit">
        <p>感谢您的支持，我会继续努力的!</p>
      </div>
      <div class="shang_payimg">
        <img src="./JavaScript 正则表达式 _ 菜鸟教程_files/weipayimg.png" alt="扫码支持" title="扫一扫">
      </div>
        <div class="pay_explain">扫码打赏，你说多少就多少</div>
      <div class="shang_payselect">
        <div class="pay_item  checked" data-id="weipay">
          <span class="radiobox"></span>
          <span class="pay_logo"><img src="./JavaScript 正则表达式 _ 菜鸟教程_files/wechat.jpg" alt="微信"></span>
        </div>
        <div class="pay_item" data-id="alipay">
          <span class="radiobox"></span>
          <span class="pay_logo"><img src="./JavaScript 正则表达式 _ 菜鸟教程_files/alipay.jpg" alt="支付宝"></span>
        </div>
        
      </div>
      <div class="shang_info">
        <p>打开<span id="shang_pay_txt">支付宝</span>扫一扫，即可进行扫码打赏哦</p>
        <p><a href="https://c.runoob.com/codedemo/5348" target="_blank"><span style=" font-size: 14px;color: #000;font-weight: bold;">点我查看本站打赏源码！</span></a></p>
      </div>
    </div>
  <div id="testClick"></div>
 <div style="display:none;">
 
 <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<script async="" src="./JavaScript 正则表达式 _ 菜鸟教程_files/js"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
</div>
<script>
window.jsui={
    www: '//wwww.runoob.com',
    uri: '//www.runoob.com/wp-content/themes/runoob'
};
</script>
<style>
ol,ul{list-style:none}.cd-switcher a{text-decoration:none;outline:0}.cd-switcher a:hover{text-decoration:underline}a:focus{outline:0;-moz-outline:0}.main_nav{width:300px;height:60px;margin:60px auto 10px auto}.main_nav li{float:left;width:60px;margin-right:10px;font-size:16px;padding:.6em 1em;border-radius:3em;background:#2f889a;text-align:center}.main_nav li a{color:#fff}.errtip{background-color:#fceaea;color:#db5353;padding:8px 15px;font-size:14px;border:1px solid #fc9797;border-radius:5px}.cd-user-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(52,54,66,0.9);z-index:3;overflow-y:auto;cursor:pointer;visibility:hidden;opacity:0;-webkit-transition:opacity .3s 0,visibility 0 .3s;-moz-transition:opacity .3s 0,visibility 0 .3s;transition:opacity .3s 0,visibility 0 .3s}.cd-user-modal.is-visible{visibility:visible;opacity:1;-webkit-transition:opacity .3s 0,visibility 0 0;-moz-transition:opacity .3s 0,visibility 0 0;transition:opacity .3s 0,visibility 0 0}.cd-user-modal.is-visible .cd-user-modal-container{-webkit-transform:translateY(0);-moz-transform:translateY(0);-ms-transform:translateY(0);-o-transform:translateY(0);transform:translateY(0)}.cd-user-modal-container{position:relative;width:90%;max-width:500px;background:#FFF;margin:3em auto 4em;cursor:auto;border-radius:.25em;-webkit-transform:translateY(-30px);-moz-transform:translateY(-30px);-ms-transform:translateY(-30px);-o-transform:translateY(-30px);transform:translateY(-30px);-webkit-transition-property:-webkit-transform;-moz-transition-property:-moz-transform;transition-property:transform;-webkit-transition-duration:.3s;-moz-transition-duration:.3s;transition-duration:.3s}.cd-user-modal-container .cd-switcher:after{content:"";display:table;clear:both}.cd-user-modal-container .cd-switcher li{width:50%;float:left;text-align:center}.cd-user-modal-container .cd-switcher li:first-child a{border-radius:.25em 0 0 0}.cd-user-modal-container .cd-switcher li:last-child a{border-radius:0 .25em 0 0}.cd-user-modal-container .cd-switcher a{font-size:1.2em;font-weight:bold;display:block;width:100%;height:50px;line-height:50px;background:#e8f1e2;color:#96b880}.cd-user-modal-container .cd-switcher a.selected{background:#FFF;color:#505260}@media only screen and (min-width:600px){.cd-user-modal-container{margin:4em auto}.cd-user-modal-container .cd-switcher a{height:70px;line-height:70px}}.cd-form{padding:1.4em}.cd-form .fieldset{position:relative;margin:1.4em 0}.cd-form .fieldset:first-child{margin-top:0}.cd-form .fieldset:last-child{margin-bottom:0}.cd-form label{font-size:16px;font-size:.875rem}.cd-form label.image-replace{display:inline-block;position:absolute;left:15px;top:50%;bottom:auto;-webkit-transform:translateY(-50%);-moz-transform:translateY(-50%);-ms-transform:translateY(-50%);-o-transform:translateY(-50%);transform:translateY(-50%);height:20px;width:20px;overflow:hidden;text-indent:100%;white-space:nowrap;color:transparent;text-shadow:none;background-repeat:no-repeat;background-position:50% 0}.cd-form label.cd-username{background-image:url("/wp-content/themes/runoob/assets/img/cd-icon-username.svg")}.cd-form label.cd-email{background-image:url("/wp-content/themes/runoob/assets/img/cd-icon-email.svg")}.cd-form label.cd-password{background-image:url("/wp-content/themes/runoob/assets/img/cd-icon-password.svg")}.cd-form input{margin:0;padding:0;border-radius:.25em}.cd-form input.full-width{width:80%}.cd-form input.full-width2{width:94%}.cd-form input.has-padding{padding:12px 20px 12px 50px}.cd-form input.has-border{border:1px solid #d2d8d8;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;appearance:none}.cd-form input.has-border:focus{border-color:#98b880;box-shadow:0 0 5px rgba(52,54,66,0.1);outline:0}.cd-form input.has-error{border:1px solid #d76666}.cd-form input[type=password]{padding-right:65px}.cd-form input[type=submit]{padding:16px 0;cursor:pointer;background:#96b97d;color:#FFF;font-weight:bold;border:0;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;appearance:none;font-size:1.2em;font-weight:bold}.no-touch .cd-form input[type=submit]:hover,.no-touch .cd-form input[type=submit]:focus{background:#3599ae;outline:0}@media only screen and (min-width:600px){.cd-form{padding:2em}.cd-form .fieldset{margin:2em 0}.cd-form .fieldset:first-child{margin-top:0}.cd-form .fieldset:last-child{margin-bottom:0}.cd-form input.has-padding{padding:16px 20px 16px 50px}.cd-form input[type=submit]{padding:16px 0}}.cd-close-form{display:block;position:absolute;width:40px;height:40px;right:0;top:-40px;background:url("/wp-content/themes/runoob/assets/img/cd-icon-close.svg") no-repeat center center;text-indent:100%;white-space:nowrap;overflow:hidden}@media only screen and (min-width:1170px){}#cd-login,#cd-signup,#cd-reset-password{display:none}#cd-login.is-selected,#cd-signup.is-selected,#cd-reset-password.is-selected{display:block}
</style>
<div class="cd-user-modal"> 
	<div class="cd-user-modal-container">
		<ul class="cd-switcher">
			<li><a href="javascript:;">用户登录</a></li>
			<li><a href="javascript:;">注册新用户</a></li>
		</ul>

		<div id="cd-login"> <!-- 登录表单 -->
			<div class="cd-form">
				<p class="fieldset">
					<label class="image-replace cd-username" for="signin-username">用户名</label>
					<input class="full-width has-padding has-border" id="signin-username" name="username" type="text" placeholder="输入用户名">
				</p>

				<p class="fieldset">
					<label class="image-replace cd-password" for="signin-password">密码</label>
					<input class="full-width has-padding has-border" id="signin-password" name="password" type="password" placeholder="输入密码">
				</p>
				
				<p class="fieldset">
					<input type="checkbox" id="remember-me" checked="">
					<label for="remember-me">记住登录状态</label>
          <a href="https://www.runoob.com/reset-password" style="float: right;padding-right: 20px;" target="_blank">忘记密码？</a>
				</p>
 				<input type="hidden" name="action" value="signin">
				<p class="fieldset">
					<input class="full-width2" type="submit" value="登 录">
				</p>
        <div class="err-msg"></div>
			</div>
		</div>

		<div id="cd-signup"> <!-- 注册表单 -->
			<div class="cd-form">
				<p class="fieldset">
					<label class="image-replace cd-password" for="verifycode">邀请码</label>
					<input class="full-width has-padding has-border" id="signup-verifycode" name="verifycode" type="text" placeholder="输入邀请码">
				</p>
				<p class="fieldset">
					<label class="image-replace cd-username" for="signup-username">用户名</label>
					<input class="full-width has-padding has-border" id="signup-username" name="name" type="text" placeholder="输入用户名">
				</p>

				<p class="fieldset">
					<label class="image-replace cd-email" for="signup-email">邮箱</label>
					<input class="full-width has-padding has-border" name="email" id="signup-email" type="email" placeholder="输入mail">
				</p>

				<p class="fieldset">
					<label class="image-replace cd-password" for="signup-password">密码</label>
					<input class="full-width has-padding has-border" id="signup-password" name="password" type="password" placeholder="输入密码">
				</p>
				<p class="fieldset">
					<label class="image-replace cd-password" for="signup-password2">重复输入密码</label>
					<input class="full-width has-padding has-border" id="signup-password2" name="password2" type="password" placeholder="重复输入密码">
				</p>
				
				<!-- 
				<p class="fieldset">
					<input type="checkbox" id="accept-terms">
					<label for="accept-terms">我已阅读并同意 <a href="javascript:;">用户协议</a></label>
				</p>
				 -->
				 
				 <input type="hidden" name="action" value="signup">
				<p class="fieldset">
					<input class="full-width2" type="submit" value="注册新用户">
				</p>
				<p class="fieldset">
				  <a href="https://www.runoob.com/w3cnote/runoob-user-test-intro.html#invite" target="_blank">如何获取邀请码？</a>
				  </p>
				<div class="err-msg"></div>
			</div>

		</div>

		<a href="javascript:;" class="cd-close-form">关闭</a>
	</div>
</div> 
<script src="./JavaScript 正则表达式 _ 菜鸟教程_files/main.min.js.下载"></script>


<ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;"><ins id="aswift_1_expand" style="display:inline-table;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><ins id="aswift_1_anchor" style="display:block;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;border:0px;width:0px;height:0px;" src="./JavaScript 正则表达式 _ 菜鸟教程_files/saved_resource(2).html"></iframe></ins></ins></ins><iframe id="google_osd_static_frame_3780346850709" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;" src="./JavaScript 正则表达式 _ 菜鸟教程_files/saved_resource(3).html"></iframe></body><iframe id="google_shimpl" style="display: none;" src="./JavaScript 正则表达式 _ 菜鸟教程_files/saved_resource(4).html"></iframe><iframe id="google_esf" name="google_esf" src="./JavaScript 正则表达式 _ 菜鸟教程_files/zrt_lookup.html" data-ad-client="ca-pub-5751451760833794" style="display: none;"></iframe></html>